//
// Created by LoveHoneyYou on 2024-11-17.
//

#ifndef WEBSERVER_WORKERTHREAD_H
#define WEBSERVER_WORKERTHREAD_H

#include "EventLoop.h"
#include <condition_variable>
#include <thread>

class WorkerThread
{
public:
    WorkerThread(int index);
    ~WorkerThread();

    void Run();

    inline EventLoop* GetEventLoop()
    {
        return event_loop_;
    }

private:
    void Running();

private:
    std::thread* thread_;
    std::thread::id thread_id_;
    std::string name_;
    std::mutex mutex_;
    std::condition_variable cond_;
    EventLoop* event_loop_;
};





#endif//WEBSERVER_WORKERTHREAD_H
